package com.jian.socks5.udp;

import com.jian.socks5.common.Constants;
import com.jian.socks5.udp.handler.Socks5UDPChannelInitializer;
import com.jian.socks5.udp.handler.UDPChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioDatagramChannel;

/***
 *
 * @author Jian
 * @date 2021.06.22
 */
public class UDPBootstrap {

    public static Bootstrap newInstance(ChannelInitializer channelInitializer) {
        Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(Constants.udpBossEventLoopGroup);
        bootstrap.channel(NioDatagramChannel.class);
        bootstrap.handler(channelInitializer);
        return bootstrap;
    }

    public static Bootstrap newSocks5DefInstance() {
        return newInstance(Socks5UDPChannelInitializer.getSocks5UDPChannelInitializer(Constants.udp_eventExecutors));
    }


    public static Bootstrap newUDPInstance() {
        return newInstance(UDPChannelInitializer.getUDPChannelInitializer(Constants.udp_eventExecutors));
    }



}
